package cn.tedu.system.base.listener;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationListener;
import org.springframework.security.authentication.event.AbstractAuthenticationFailureEvent;
import org.springframework.security.authentication.event.AuthenticationFailureBadCredentialsEvent;
import org.springframework.security.authentication.event.AuthenticationFailureLockedEvent;
import org.springframework.stereotype.Component;

@Component
public class AuthenticationFailureListener implements ApplicationListener<AbstractAuthenticationFailureEvent> {
    private static final Logger log=
            LoggerFactory.getLogger(AuthenticationFailureListener.class);
    @Override
    public void onApplicationEvent(AbstractAuthenticationFailureEvent event) {
        if(event instanceof AuthenticationFailureBadCredentialsEvent){
            log.info("密码无效");
        }else if(event instanceof AuthenticationFailureLockedEvent){
            log.info("账号被锁定");
        }//else if(...)
    }
}
